﻿using LeakView.common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LeakView
{
    class AppConfig
    {
        static AppConfig()
        {
            //HeadName = GetValueFromConfig("APP", "HeadName");
            //TailName = GetValueFromConfig("APP", "TailName");
        }

        public static string HeadName
        {
            get
            {
                try
                {
                    var v = GetValueFromConfig("APP", "HeadName");
                    if (v.Count() == 0)
                    {
                        v = "上游";
                    }
                    return v;
                }
                catch
                {
                    return "上游";
                }

            }

        }

        public static string TailName
        {
            get
            {
                try
                {
                    var v = GetValueFromConfig("APP", "TailName");
                    if (v.Count() == 0)
                    {
                        v = "下游";
                    }
                    return v;
                }
                catch
                {
                    return "下游";
                }
            }

        }

        private static string GetValueFromConfig(string section, string key)
        {
            var config = AnyConfigs.get(section);
            var value = config.get(key).Get<string>();
            return value;
        }
    }
}
